<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    
    <!-- 引入 echarts.js -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Bootstrap -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <title>ECharts</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/4.1.0/echarts-en.common.js"></script>
    <style>
    .container {
        width: 800px;
    }

    #main {
        height: 600px;
        width: 800px;
        margin: 20px auto;
    }
    </style>
</head>
<body>
    <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
    <div class="container">
        <h1>期末作业 <small>数据可视化</small></h1>
        <div id="main"></div>
        <div class="panel panel-primary">
            <div class="panel-heading">数据来源</div>
            <div class="panel-body">
                <p><li><a href="http://index.baidu.com/Helper/?tpl=brand&word=">百度指数</a></li></p>
                
            </div>
        </div>
    </div>
    <script type="text/javascript">
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));

        // 指定图表的配置项和数据
  
var data = [
    [[28604,77,17096869,'Welcome To New York',2018],[31163,77.4,27662440,'Blank Space',2018],[11516,2,1154605773,'Style',1990],[13670,74.7,10582082,'Out Of The Woods',1990],[28599,75,4986705,'All You Had Do Was Stay',2018],[29476,77.1,56943299,'Shake It Off',2018],[31476,75.4,78958237,'I Wish You Would',2018],[28666,78.1,254830,'Bad Blood',2018],[1777,57.7,870601776,'Wildest Dreams',2018],[29550,79.1,122249285,'How You Get The Girl',2018],[2076,67.9,20194354,'This Love',2018],[12087,72,42972254,'I Know Places',2018],[24021,75.4,3397534,'Clean',2018],[43296,76.8,4240375,'Wonderland',2018],[10088,70.8,38195258,'You Are In Love',2018],[19349,69.6,147568552,'New Romance',2018],[10670,67.3,53994605,'I Know Places(piano)',2018],[26424,75.7,57110117,'I Wish You Would(track)',2018],[37062,75.4,252847810,'Blank Space(guitars)',2018]],
    [[44056,81.8,23968973,'Welcome To New York',2015],[43294,81.7,35939927,'Blank Space',2015],[13334,76.9,1376048943,'Style',2015],[21291,78.5,11389562,'Out Of The Woods',2015],[38923,80.8,5503457,'All You Had Do Was Stay',2015],[37599,81.9,64395345,'Shake It Off',2015],[44053,81.1,80688545,'I Wish You Would',2015],[42182,82.8,329425,'Bad Blood',2015],[5903,66.8,1311050527,'Wildest Dreams',2015],[36162,83.5,126573481,'How You Get The Girl',2015],[1390,71.4,25155317,'This Love',2015],[34644,80.7,50293439,'I Know Places',2015],[34186,80.6,4528526,'Clean',2015],[64304,81.6,5210967,'Wonderland',2015],[24787,77.3,38611794,'You Are In Love',2015],[23038,73.13,143456918,'New Romance',2015],[19360,76.5,78665830,'I Know Places(piano)',2015],[38225,81.4,64715810,'I Wish You Would(track)',2015],[53354,79.1,321773631,'Blank Space(guitars)',2015]]
];

 var option = {
    backgroundColor: new echarts.graphic.RadialGradient(0.3, 0.3, 0.8, [{
        offset: 0,
        color: '#f7f8fa'
    }, {
        offset: 1,
        color: '#cdd0d5'
    }]),
    title: {
        text: '2018 与 2015 年taylor swift专辑《1989》歌曲的销量'
    },
    legend: {
        right: 10,
        data: ['2018', '2015']
    },
    xAxis: {
        splitLine: {
            lineStyle: {
                type: 'dashed'
            }
        }
    },
    yAxis: {
        splitLine: {
            lineStyle: {
                type: 'dashed'
            }
        },
        scale: true
    },
    series: [{
        name: '2018',
        data: data[0],
        type: 'scatter',
        symbolSize: function (data) {
            return Math.sqrt(data[2]) / 5e2;
        },
        label: {
            emphasis: {
                show: true,
                formatter: function (param) {
                    return param.data[3];
                },
                position: 'top'
            }
        },
        itemStyle: {
            normal: {
                shadowBlur: 10,
                shadowColor: 'rgba(120, 36, 50, 0.5)',
                shadowOffsetY: 5,
                color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{
                    offset: 0,
                    color: 'rgb(251, 118, 123)'
                }, {
                    offset: 1,
                    color: 'rgb(204, 46, 72)'
                }])
            }
        }
    }, {
        name: '2015',
        data: data[1],
        type: 'scatter',
        symbolSize: function (data) {
            return Math.sqrt(data[2]) / 5e2;
        },
        label: {
            emphasis: {
                show: true,
                formatter: function (param) {
                    return param.data[3];
                },
                position: 'top'
            }
        },
        itemStyle: {
            normal: {
                shadowBlur: 10,
                shadowColor: 'rgba(25, 100, 150, 0.5)',
                shadowOffsetY: 5,
                color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{
                    offset: 0,
                    color: 'rgb(129, 227, 238)'
                }, {
                    offset: 1,
                    color: 'rgb(25, 183, 207)'
                }])
            }
        }
    }]
};
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    </script>
     <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>